package com.briup.recognition.service.impl;


import com.briup.recognition.bean.BaseUser;
import com.briup.recognition.bean.BaseUserExample;
import com.briup.recognition.dao.BaseUserMapper;
import com.briup.recognition.service.IBaseUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author: kun
 * @Description: 调用dao层
 * @DateTime: 2021/3/28$ 23:18$
 * @Params: $
 * @Return $
 */
@Service
public class BaseUserServiceImpl implements IBaseUserService {
    @Resource
    private BaseUserMapper baseUserMapper;

    @Override
    public List<BaseUser> query(){
        BaseUserExample example = new BaseUserExample();
        return  baseUserMapper.selectByExample(example);
    }

    @Override
    public  void  saveOrUpdate(BaseUser baseUser){
        if(baseUser.getId()!=null){
            baseUserMapper.updateByPrimaryKey(baseUser);
        }else {
            baseUser.setRegisterTime(new Date().getTime());
            baseUserMapper.insert(baseUser);
        }
    }

    @Override
    public  void  deleteById(long id){
        baseUserMapper.deleteByPrimaryKey(id);
    }

}